package com.njworkorder.HTSingleLogin;

/**
 * 开发业务常量
 *
 * @author ht_lzc
 * @date 2024/8/6 14:17
 */
public interface ServerConstants {
    String CACHE_NAME_BASE_DISEASE_LIST_VALUE = "DISEASE_LIST_VALUE";
    String CACHE_NAME_BASE_DISEASE_LIST_KEY = "'DISEASE_LIST_KEY'";
    String CACHE_NAME_BASE_COMPONENT_TEMPLATE_VALUE = "COMPONENT_TEMPLATE_VALUE";
    String CACHE_NAME_BASE_COMPONENT_TEMPLATE_KEY_ONE = "'COMPONENT_TEMPLATE_KEY_ONE'";
    String CACHE_NAME_BASE_COMPONENT_TEMPLATE_KEY_TWO = "'COMPONENT_TEMPLATE_KEY_TWO'";
    String CACHE_NAME_BASE_COMPONENT_TEMPLATE_KEY_THREE = "'COMPONENT_TEMPLATE_KEY_THREE'";

    /**
     * 综管公司类型
     */
     enum OrgType {
        单位("o"),
        部门("ou"),
        虚拟单位("ov");
        private String code;
        OrgType(String code) {
            this.code = code;
        }
        public String getCode() {
            return code;
        }
    }


    /**
     * 更新或新增是否成功 0为失败 1为成功
     * 当要增加的信息已存在时,返回为-1
     */
    Integer UPDATE_SUCCESS = 1;
    Integer UPDATE_FAIL = 0;
    Integer UPDATE_EXISTS = -1;
    String ROUTE_TOKEN ="route_token";

    String BRIDGE_INFO_TOKEN="bridge_info_token";

    String ROAD_ORGANIZATION_TOKEN="road_organization_token";

    String JK_TOKEN="jk_token";


    /**
     * 构件的所属性质
     */
     enum ComponentPropertyEnum {
        公有(1),
        私有(0);
        private Integer code;
        ComponentPropertyEnum(Integer code) {
            this.code = code;
        }
        public Integer getCode() {
            return code;
        }
    }


    /**
     * 档案类型字典项
     */

    String ARCHIVE_TYPE_DICT_CODE = "bridge_archive_type";


    /**
     * 5大检查类型常量字典
     */
    enum InspectTypeDictEnum {

        初始检查("CS"),
        经常检查("JC"),
        定期检查("DQ"),
        日常巡查("RC"),
        特殊检查("TS");


        private String code;

        InspectTypeDictEnum(String code) {
            this.code = code;
        }

        public String getCode() {
            return code;
        }
    }


    /**
     * 任务类型
     */
    enum  TaskTypeEnum {
        系统录入(0,"X","系统录入"),
        数据对接(1,"S","数据对接");

        private Integer code;


        private String letterCode;


        private String name;

        TaskTypeEnum(Integer code, String letterCode, String name) {
            this.code = code;
            this.letterCode = letterCode;
            this.name = name;
        }

        /**
         * 根据code获取简码letterCode
         */

        public static TaskTypeEnum getTaskTypeByCode(Integer code) {
            for (TaskTypeEnum taskType : TaskTypeEnum.values()) {
                if (taskType.code.equals(code))
                {
                    return taskType;
                }
            }
            return null;
        }

        public Integer getCode() {
            return code;
        }

        public String getLetterCode() {
            return letterCode;
        }

        public String getName() {
            return name;
        }
    }

    /**
     * 检查类型对应的数据表
     */

    enum InspectTypeTableEnum {

        日常巡查("RCXC","t_inspect_rcxc_task"),
        经常检查("JCXC","t_inspect_jcxc_task"),
        定期检查("DQXC","t_inspect_dqxc_task"),
        特数检查("TSJC","t_inspect_tsjc_task");
        private String inspectType;
        private String tableName;
        InspectTypeTableEnum(String inspectType, String tableName) {
            this.inspectType = inspectType;
            this.tableName = tableName;
        }


        /**
         * 根据检查类型获取对应的检查枚举
         */

        public static InspectTypeTableEnum getInspectTypeTableEnumByInspectType(String inspectType) {
            for (InspectTypeTableEnum inspectTypeTableEnum : InspectTypeTableEnum.values()) {
                if (inspectType.equals(inspectTypeTableEnum.inspectType))
                {
                    return inspectTypeTableEnum;
                }
            }
            return null;
        }

        public String getTableName() {
            return tableName;
        }

        public String getInspectType() {
            return inspectType;
        }
    }

    /**
     * 流程定义枚举类
     */
    enum FlowEnum {
        检查类流程("flow_ddo78dp3","JC"),
        维修类流程("JCXC","WX");

        private String code;

        private String type;


        FlowEnum(String code, String type) {
            this.code = code;
            this.type = type;
        }

        public String getCode() {
            return code;
        }

        public String getType() {
            return type;
        }
    }

    /**
     * 病害状态
     */
    enum DiseaseEnum {
        未维修("0"),
        维修中("1"),
        已维修("2");

        private String code;


        public String getCode() {
            return code;
        }

        DiseaseEnum(String code) {
            this.code = code;
        }
    }

    /**
     * 检查类流程节点状态
     */
    enum InspectNodeStatus {
        待开始(0),
        待完成(1);


        private Integer statusCode;

        public Integer getStatusCode() {
            return statusCode;
        }

        InspectNodeStatus(Integer statusCode) {
            this.statusCode = statusCode;
        }
    }


    /**
     * 检查流程分类
     */
    enum InspectProcessType {
        日常巡查("RCXC"),
        经常检查("JCJC"),
        定期检查("DQJC"),
        特殊检查("TSJC");

        private String inspectTypeCode;

        public String getInspectTypeCode() {
            return inspectTypeCode;
        }

        InspectProcessType(String inspectTypeCode) {
            this.inspectTypeCode = inspectTypeCode;
        }


        /**
         * 根据检查类型Code查询枚举项
         */
        public static InspectProcessType getInspectProcessTypeByInspectTypeCode(String inspectTypeCode) {
            for (InspectProcessType inspectProcessType : InspectProcessType.values()) {
                if (inspectProcessType.inspectTypeCode.equals(inspectTypeCode)) {
                    return inspectProcessType;
                }
            }
            return null;
        }

    }


    /**
     * 获取定检的t值
     */
    public enum DqTValueEnum {
        T1(1,1000000000000000.000),
        T2(2,10.0),
        T3(3,9.7),
        T4(4,9.5),
        T5(5,9.2),
        T6(6,8.9),
        T7(7,8.7),
        T8(8,8.5),
        T9(9,8.3),
        T10(10,8.1),
        T11(11,7.9),
        T12(12,7.7),
        T13(13,7.5),
        T14(14,7.3),
        T15(15,7.2),
        T16(16,7.08),
        T17(17,6.96),
        T18(18,6.84),
        T19(19,6.72),
        T20(20,6.6),
        T21(21,6.48),
        T22(22,6.36),
        T23(23,6.24),
        T24(24,6.12),
        T25(25,6.0),
        T26(26,5.88),
        T27(27,5.76),
        T28(28,5.64),
        T29(29,5.52),
        T30(30,5.4),
        T40(40,4.9),
        T50(50,4.4),
        T60(60,4.0),
        T70(70,3.6),
        T80(80,3.2),
        T90(90,2.8),
        T100(100,2.5),
        T200(200,2.3);



        private Integer t;
        private Double value;

        DqTValueEnum(Integer t, Double value) {
            this.t = t;
            this.value = value;
        }

        public Integer getT() {
            return t;
        }

        public Double getValue() {
            return value;
        }

        public static Double getTValue(Integer t) {
            for (DqTValueEnum dqTValueEnum : DqTValueEnum.values()) {
                if (t == dqTValueEnum.getT())
                {
                    return dqTValueEnum.getValue();
                }
            }
            //其他情况进行加权取值
            if (t >= 200) {
                return T200.getValue();
            }else if (t >= 100) {
                int d = t - 100;
                return T100.getValue()+ d*(T200.getValue()- T100.getValue())/100;
            }else if (t >= 90) {
                int d = t - 90;
                return T90.getValue()+ d*(T100.getValue()- T90.getValue())/10;
            }else if (t >= 80) {
                int d = t - 80;
                return T80.getValue()+ d*(T90.getValue()- T80.getValue())/10;
            }else if (t >= 70) {
                int d = t - 70;
                return T70.getValue()+ d*(T80.getValue()- T70.getValue())/10;
            }else if (t >= 60) {
                int d = t - 60;
                return T60.getValue()+ d*(T70.getValue()- T60.getValue())/10;
            }else if (t >= 50) {
                int d = t - 50;
                return T50.getValue()+ d*(T60.getValue()- T50.getValue())/10;
            }else if (t >= 40) {
                int d = t - 40;
                return T40.getValue()+ d*(T50.getValue()- T40.getValue())/10;
            }else if (t >= 30) {
                int d = t - 30;
                return T30.getValue()+ d*(T40.getValue()- T30.getValue())/10;
            }
            return null;
        }
    }


    enum EVALUATEENUM
    {
        I类(1),
        II类(2),
        III类(3),
        IV类(4),
        V类(5);

        public Integer level;

        EVALUATEENUM(Integer level) {
            this.level = level;
        }

        /**
         * 根据定检级别获取对应的枚举
         */
        public static EVALUATEENUM getEvaluateEnumByLevel(Integer level) {
            for (EVALUATEENUM evaluateEnum : EVALUATEENUM.values()) {
                if (evaluateEnum.level.equals(level)) {
                    return evaluateEnum;
                }
            }
            return null;
        }
    }


}
